<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->increments('id');
            $table->string('order_sn')->nullable()->comment('订单号');
            $table->integer('user_id')->nullable()->comment('用户id');
            $table->integer('order_status')->default(0)->comment('订单状态 0，未确认；1，已确认；2，已取消；3，无效；4，退货；');
            $table->integer('shipping_status')->default(0)->comment('订单派送状态 0，未发货；1，已发货；2，已收货；3，备货中');
            $table->integer('pay_status')->default(0)->comment('支付状态；0，未付款；1，付款中；2，已付款');
            $table->string('consignee')->nullable()->comment('收货人的姓名，用户页面填写，默认取值于表user_address');
            $table->string('country')->nullable()->comment('收货人的国家，用户页面填写，默认取值于表user_address');
            $table->string('province')->nullable()->comment('收货人的省份，用户页面填写，默认取值于表user_address');
            $table->string('city')->nullable()->comment('收货人的城市，用户页面填写，默认取值于表user_address');
            $table->string('district')->nullable()->comment('收货人的地区，用户页面填写，默认取值于表user_address');
            $table->string('address')->nullable()->comment('收货人的详细地址，用户页面填写');
            $table->string('zipcode')->nullable()->comment('收货人的邮编，用户页面填写');
            $table->string('mobile')->nullable()->comment('收货人的手机');
            $table->string('remark')->nullable()->comment('备注信息');
            $table->integer('coupon_id')->default(0)->comment('优惠券id');
            $table->integer('pay_id')->default(0)->comment('支付方式id');
            $table->string('pay_name')->nullable()->comment('支付方式名称');
            $table->decimal('pay_fee',10,2)->default('0.00')->comment('订单金额');
            $table->decimal('discount',10,2)->default('0.00')->comment('优惠金额');
            $table->decimal('money_paid',10,2)->default('0.00')->comment('支付金额');
            $table->integer('add_time')->nullable()->comment('订单新增时间');
            $table->integer('pay_time')->nullable()->comment('订单支付时间');
            $table->integer('shipping_time')->nullable()->comment('订单配送时间');
            $table->integer('finish_time')->nullable()->comment('订单完成时间');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
